﻿using GuanQL.Core.Domain.Accounts;
using System;
using System.Collections.Generic;
using System.Linq;
namespace GuanQL.Core
{
    public class UserModel
    {
        public UserModel(User user)
        {
            Id = user.Id;
            Name = user.GetDisplayName();
            Mobile = user.PhoneNumber;
            TenantId = user.TenantId;
            Role = user.Roles.Select(r => r.Role.Name);
        }

        public Guid Id { get; set; }

        public string Name { get; set; }

        public string Mobile { get; set; }

        public Guid TenantId { get; set; }

        public IEnumerable<string> Role { get; set; }

        public bool IsPropertyManager()
        {
            return Role.Contains(GlobleConsts.Role.PropertyManager);
        }

        public bool IsAdmin()
        {
            return Role.Contains(GlobleConsts.Role.Admin);
        }

        public bool IsAgents()
        {
            return Role.Contains(GlobleConsts.Role.Agents);
        }

        public bool IsSecurity()
        {
            return Role.Contains(GlobleConsts.Role.Security);
        }
    }
}
